cmake_minimum_required(VERSION 3.16)

project(focusHost VERSION 0.1 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# MSVC specific flags for C++17 compliance
if(MSVC)
    add_compile_options(/Zc:__cplusplus /permissive- /utf-8)
endif()

find_package(Qt6 REQUIRED COMPONENTS Core Quick SerialPort)

qt_standard_project_setup(REQUIRES 6.8)

qt_add_executable(appfocusHost
    main.cpp
    serialportcontroller.h
    serialportcontroller.cpp
    protocolhandler.h
    protocolhandler.cpp
    communicationlogger.h
    communicationlogger.cpp
    # To add an application icon:
    # 1. Add an icon file (e.g., appicon.ico for Windows, appicon.icns for macOS)
    # 2. Uncomment and configure the line below:
    # WIN32_EXECUTABLE_ICON appicon.ico
)

qt_add_qml_module(appfocusHost
    URI focusHost
    VERSION 1.0
    QML_FILES
        Main.qml
)

# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# If you are developing for iOS or macOS you should consider setting an
# explicit, fixed bundle identifier manually though.
set_target_properties(appfocusHost PROPERTIES
#    MACOSX_BUNDLE_GUI_IDENTIFIER com.example.appfocusHost
    MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
    MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
    MACOSX_BUNDLE TRUE
    WIN32_EXECUTABLE TRUE
)

target_link_libraries(appfocusHost
    PRIVATE Qt6::Quick Qt6::SerialPort
)

include(GNUInstallDirs)
install(TARGETS appfocusHost
    BUNDLE DESTINATION .
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
